<template>
  <transition name="el-fade-in">
    <div class="lse_loading_body" :style="{zIndex: index}" v-if="flag">
        <div class="lse_loading_content">
            <div>
                <div v-if="type === 1" class="spinnerA">
                    <div class="rect1"></div>
                    <div class="rect2"></div>
                    <div class="rect3"></div>
                    <div class="rect4"></div>
                    <div class="rect5"></div>
                </div>
                <div v-else-if="type === 2" class="spinnerB">
                    <div class="bounce1"></div>
                    <div class="bounce2"></div>
                    <div class="bounce3"></div>
                </div>
                <div class="spinnerC" v-else-if="type === 3"></div>
            </div>
            <div style="margin-top: 10px;">{{msg}}</div>
        </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'loading',
  data () {
    return {
      flag: false,
      index: 99999,
      msg: '',
      type: 3
    }
  },
  methods: {
    close () {
      this.flag = false
    }
  },
  created () {}
}
</script>

<style scoped>
.lse_loading_body{
    width: 100%;
    height: 100%;
    position: fixed;
    text-align: center;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.2);
    z-index: 999999;
    padding: 10px;
}
.lse_loading_content{
    width: 100%;
    position: fixed;
    text-align: center;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
}
/* 加载动画 A */
.spinnerA {
  margin: auto;
  width: 50px;
  height: 60px;
  text-align: center;
  font-size: 10px;
}

.spinnerA > div {
  background-color: #409EFF;
  height: 100%;
  width: 6px;
  display: inline-block;
  -webkit-animation: stretchdelay 1.2s infinite ease-in-out;
  animation: stretchdelay 1.2s infinite ease-in-out;
}

.spinnerA .rect2 {
  -webkit-animation-delay: -1.1s;
  animation-delay: -1.1s;
}

.spinnerA .rect3 {
  -webkit-animation-delay: -1.0s;
  animation-delay: -1.0s;
}

.spinnerA .rect4 {
  -webkit-animation-delay: -0.9s;
  animation-delay: -0.9s;
}

.spinnerA .rect5 {
  -webkit-animation-delay: -0.8s;
  animation-delay: -0.8s;
}

@-webkit-keyframes stretchdelay {
  0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
  20% { -webkit-transform: scaleY(1.0) }
}

@keyframes stretchdelay {
  0%, 40%, 100% {
    transform: scaleY(0.4);
    -webkit-transform: scaleY(0.4);
  }
  20% {
    transform: scaleY(1.0);
    -webkit-transform: scaleY(1.0);
  }
}
/* 加载动画 B */
.spinnerB {
  margin: auto;
  width: 150px;
  text-align: center;
}
.spinnerB > div {
  width: 30px;
  height: 30px;
  background-color: #409EFF;
  border-radius: 100%;
  display: inline-block;
  -webkit-animation: bouncedelay 1.4s infinite ease-in-out;
  animation: bouncedelay 1.4s infinite ease-in-out;
  /* Prevent first frame from flickering when animation starts */
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

.spinnerB .bounce1 {
  -webkit-animation-delay: -0.32s;
  animation-delay: -0.32s;
}

.spinnerB .bounce2 {
  -webkit-animation-delay: -0.16s;
  animation-delay: -0.16s;
}

@-webkit-keyframes bouncedelay {
  0%, 80%, 100% { -webkit-transform: scale(0.0) }
  40% { -webkit-transform: scale(1.0) }
}

@keyframes bouncedelay {
  0%, 80%, 100% {
    transform: scale(0.0);
    -webkit-transform: scale(0.0);
  }
  40% {
    transform: scale(1.0);
    -webkit-transform: scale(1.0);
  }
}
/* 加载动画 C */
.spinnerC {
  width: 50px;
  height: 50px;
  margin: auto;
  background-color: #409EFF;
  border-radius: 100%;
  -webkit-animation: scaleout 1.0s infinite ease-in-out;
  animation: scaleout 1.0s infinite ease-in-out;
}

@-webkit-keyframes scaleout {
  0% { -webkit-transform: scale(0.0) }
  100% {
    -webkit-transform: scale(1.0);
    opacity: 0;
  }
}

@keyframes scaleout {
  0% {
    transform: scale(0.0);
    -webkit-transform: scale(0.0);
  }
  100% {
    transform: scale(1.0);
    -webkit-transform: scale(1.0);
    opacity: 0;
  }
}
</style>
